package Dao.impl;/*
 *徐韬
 *2021/10/9
 *12:40
 */

import Dao.CategoryDao;
import Util.DruidUtil;
import entity.Category;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CategoryDaoimpl implements CategoryDao {
    QueryRunner queryRunner = new QueryRunner();
    @Override
    public List<Category> selectAll() {
        try {
            return queryRunner.query(DruidUtil.getConnection(),"select * from category", new BeanListHandler<>(Category.class));
        } catch (SQLException e) {
            throw new RuntimeException(e.getMessage()+"查询分类出现异常");
        }
    }
}
